import * as api from '../api'
export default(state,action)=>{
    state = state || {songList:[],topInfo:{},totalSongNum:0,updateTime:''};
    switch(action.type){
        case 'list_init':
            return {songList:action.songList,topInfo:action.topInfo,totalSongNum:action.totalSongNum,updateTime:action.updateTime}
        default:
            return state;
    }
}
export const getSongList = (id) => (dispatch) => {
    fetch(api.SONG_LIST + id).then(response=>response.json()).then(result=>{
        dispatch({type:'list_init',songList:result.data.songList,topInfo:result.data.topInfo,totalSongNum:result.data.totalSongNum,updateTime:result.data.updateTime})
    })
}